/* $Header: iq_cmds.c,v 2.2 01/10/02 10:29:19 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME: iq_cmds.c                                              */
/* ============                                                        */
/*                                                                     */
/* Author:  Bob Cook                                                   */
/*                                                                     */
/* MODULE PURPOSE: This module will handle the IQ comm commands.       */
/*    This module was added because of dependences between the oven,   */
/*    inlet, detector, and column. Individual commands to these        */
/*    sections are placed in the IQ_Cmd_Q and executed in the order    */
/*    that they arrive.  The workfile commands are already executed    */
/*    in the order of arrival.                                         */
/*                                                                     */
/***********************************************************************/

/*
 */

/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>

#include <error.h>

#include <mio.h>
#include <cmd_set.h>
#include <cmdproc.h>
#include <method.h>
#include <hostutil.h>


/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/



/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/

extern CMD_QUEUE_TYPE  IQ_Cmd_Q;

/*****************************/
/*   LOCAL DEFINES           */
/*****************************/


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   MACROS                  */
/*****************************/




/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/



/***********************************************************************/
/* FUNCTION: DoIQEO                                                    */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: Echo command.                                              */
/*                                                                     */
/* RETURNED VALUE: length of response string                           */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

INT16 DoIQEO(CMD_TYPE *p_cmd,BIT8  *p_resp_parm)
{
U_INT16 len;

   len = 0;

   if (p_cmd->parmv[0] == 1)
   {
      len = PutAsciiParam((BIT8 *)"\"", p_resp_parm);
      len += PutAsciiParam((BIT8 *)&(p_cmd->parms[p_cmd->parmv[1]]),
                                     p_resp_parm+len);
      len += PutAsciiParam((BIT8 *)"\"", p_resp_parm+len);
      return len;
   }
   else
   {
      CmdErrorHandler(p_cmd,1,INVALID_PARAM);
      return NO_RESPONSE;
   }
}

/***********************************************************************/
/* END FUNCTION: DoIQEO                                                */
/***********************************************************************/




/***********************************************************************/
/* FUNCTION: IQOpcodes                                                 */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calls routines needed to implement the IQ commands.        */
/*    This function was added because of dependences between the oven, */
/*    inlet, detector, and column. Individual commands to these        */
/*    sections are placed in the IQ_Cmd_Q and executed in the order    */
/*    that they arrive.  The workfile commands are already executed    */
/*    in the order of arrival.                                         */
/*                                                                     */
/* RETURNED VALUE: none                                                */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

INT16 IQOpcodes(CMD_TYPE  *p_cmd,BIT8  *p_resp_parm,U_INT16 max_resp_len)
{
/*--------------changed by wangwei-----------------------*/
INT16           parm_len;

   (void) max_resp_len;

   parm_len = NO_RESPONSE;
   if ( p_cmd->opcode.int_op  == MAKEINT('E','O') )
   {
      parm_len = DoIQEO(p_cmd,p_resp_parm);
   }
   else
   {
      switch (p_cmd->dsap.int_dsap)
      {
         case MAKEINT('G','C'):
            parm_len = GCOpcodes(p_cmd,p_resp_parm, max_resp_len);
            break;
 /*
         case MAKEINT('O','V'):
            parm_len = OVOpcodes(p_cmd,p_resp_parm, max_resp_len);
            break;
         case MAKEINT('I','F'):
         case MAKEINT('I','B'):
            parm_len = IXOpcodes(p_cmd, p_resp_parm, max_resp_len);
            break;
*/
         case MAKEINT('D','F'):
         case MAKEINT('D','B'):
            parm_len = DXOpcodes(p_cmd, p_resp_parm, max_resp_len);
            break;
/*
         case MAKEINT('C','1'):
         case MAKEINT('C','2'):
            parm_len = CXOpcodes(p_cmd, p_resp_parm, max_resp_len);
            break;
*/
         case MAKEINT('A','1'):
         case MAKEINT('A','2'):
         case MAKEINT('A','3'):
         case MAKEINT('A','4'):
         case MAKEINT('A','5'):
            parm_len = AXOpcodes(p_cmd, p_resp_parm, max_resp_len);
            break;
/*
         case MAKEINT('V','1'):
         case MAKEINT('V','2'):
         case MAKEINT('V','3'):
         case MAKEINT('V','4'):
         case MAKEINT('V','5'):
         case MAKEINT('V','6'):
         case MAKEINT('V','7'):
         case MAKEINT('V','8'):
         case MAKEINT('V','X'):
            parm_len = VXOpcodes(p_cmd, p_resp_parm, max_resp_len);
            break;
*/
         default:
            parm_len = NO_RESPONSE;
            CmdErrorHandler(p_cmd,0,INVALID_OP);
            break;
      }
   }
   return parm_len;
/*------------------end change--------------------*/
}


/***********************************************************************/
/* END FUNCTION: IQOpcodes                                             */
/***********************************************************************/



/***********************************************************************/
/* FUNCTION: IQ_Cmds                                                   */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calls function which executes a command if one is          */
/*          available on the command queue.                            */
/*                                                                     */
/* RETURNED VALUE: none                                                */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* FILE SCOPE STATICS USED:                                            */
/*                                                                     */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

void IQ_Cmds(void)
{
   ExecCmds(&IQ_Cmd_Q,IQOpcodes);
}

/***********************************************************************/
/* END FUNCTION: DX_Cmds                                               */
/***********************************************************************/

